package com.pkx.cloud.fse7.expand.plan.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.expand.plan.entity.DoorPlan;
import com.pkx.cloud.fse7.expand.plan.service.DoorPlanService;
import com.pkx.cloud.whzx.comn.ORpose;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 控制器
 *
 * @author chenwg
 * @since 2021-04-09
 */
@RestController
@RequestMapping("/plan/door-plan")
@Api(value = "门禁计划", tags = "门禁计划")
@Slf4j
@ORpose
public class DoorPlanController {

    @Autowired
    private DoorPlanService doorPlanService;

    @ApiOperation("分页列表")
    @GetMapping("/page")
    public Page<DoorPlan> page(Page page, DoorPlan doorPlan) {
        return doorPlanService.pageList(page, doorPlan);
    }

    @ApiOperation("列表")
    @GetMapping("/list")
    public List<DoorPlan> list(DoorPlan doorPlan) {
        return doorPlanService.listByEntity(doorPlan);
    }

    @ApiOperation("详情")
    @GetMapping(value = "/{id}")
    public DoorPlan selectById(@PathVariable("id") String id) {
        return doorPlanService.selectById(id);
    }

    @ApiOperation("新增")
    @PostMapping("")
    public Boolean add(@RequestBody DoorPlan doorPlan) {
        return doorPlanService.saveDoorPlan(doorPlan);
    }

    @ApiOperation("修改")
    @PutMapping("")
    public Boolean modify(@RequestBody DoorPlan doorPlan) {
        return doorPlanService.modify(doorPlan);
    }

    @ApiOperation("删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    public Boolean deleteById(@PathVariable("id") String id) {
        return doorPlanService.deleteById(id);
    }

    @ApiOperation("删除(多个条目)")
    @DeleteMapping(value = "/batch/{ids}")
    public Boolean deleteByIds(@PathVariable("ids") List<String> ids) {
        return doorPlanService.deleteByIds(ids);
    }

}
